package com.xs.ai.limiter;

import com.google.common.util.concurrent.RateLimiter;
import org.springframework.stereotype.Component;

@Component
public class DynamicRateLimiter {

    private volatile RateLimiter rateLimiter = RateLimiter.create(100.0); // 每秒100个

    public boolean tryAcquire() {
        return rateLimiter.tryAcquire();
    }

    public void updateRate(double newRate) {
        rateLimiter = RateLimiter.create(newRate);
    }
}
